package com.cbank.dao;

import com.cbank.domain.BaseEntity;
import com.cbank.domain.Module;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface ModuleDao {
    public static final String ALL="id,name,create_time,update_time,english_name";

    @Select("select "+ALL+" from module where status = "+ BaseEntity.STATUS_VALID)
    List<Module> getAll();

    @Select("select "+ALL+" from module where id = #{id}")
    Module getById(Integer id);

    @Select("select "+ALL+" from module where view_id = #{viewId}")
    Module getByViewId(String viewId);

    @Insert("insert into module (name,english_name) values(#{name},#{englishName})")
    void insert(Module module);

    @Update("update module set view_id=#{viewId},name=#{name},create_time=#{createTime},update_time=#{updateTime},english_name=#{englishName} where id = #{id}")
    void update(Module module);
}
